<admintpl file="header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			
			<li class="active">添加楼宇</li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form" action="{:U('Guanlixiaoqu/fwadd_post')}">
			<fieldset>
				
				<div class="control-group">
					<label class="control-label">选择小区:</label>
                                        
					<div class="controls">
                                           
						<select  onchange="xl();" id="xq">
                                                      <option selected="selected" >请选择小区</option>
                                                      <foreach name="xqs" item="v">
                                                  
                                                    <option value="{$v.id}">{$v.name}</option>
                                                   </foreach>    
						</select>
                                              
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">选择楼宇:</label>
					<div class="controls">
						
                                            <select name="buildingid" id="ly" onchange="fw();">
                                                   
						</select>
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">选择单元号:</label>
					<div class="controls">
						
                                                 <select name="dynumber" id="dy" onchange="dy();">
                                                   
						</select>
						<span class="form-required">*</span>
					</div>
				</div>
			
				<div class="control-group">
					<label class="control-label">所在楼层:</label>
					<div class="controls">
						<input type="text" name="louceng">
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">房号:</label>
					<div class="controls">
						<input type="text" name="housenumber" id="action">
						<span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">建筑面积:</label>
					<div class="controls">
						<input type="text" name="jzmianji" id="action">
                                                <span class="form-required">*</span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">套内面积:</label>
                                        <div class="controls">
				                <input type="text" name="tnmianji" id="action">
                                                <span class="form-required">*</span>
				</div>
                                        </div>
                            	<div class="control-group">
					<label class="control-label">公摊面积:</label>
					<div class="controls">
						<input type="text" name="gtmianji" id="action">
                                                <span class="form-required">*</span>
					</div>
				</div>
                            <div class="control-group">
					<label class="control-label">房屋类型:</label>
					<div class="controls">
						<input type="text" name="housetype" id="action">
                                                <span class="form-required">*</span>
					</div>
				</div>
                             <div class="control-group">
					<label class="control-label">房屋状态:</label>
					<div class="controls">
						<input type="text" name="housestate" id="action">
                                                <span class="form-required">*</span>
					</div>
				</div>
				<input type="text" style="display: none" name="xqname" id="xqyc"  value="" >
                                <input type="text" style="display: none" name="lyname" id="lyyc"  value="" >
			</fieldset>
			<div class="form-actions">
				<button type="submit" class="btn btn-primary js-ajax-submit">{:L('ADD')}</button>
				<a class="btn" href="{:U('Guanlixiaoqu/louyuguanli')}">{:L('BACK')}</a>
			</div>
		</form>
	</div>
	<!--<script src="__PUBLIC__/js/common.js"></script>-->
        <script src="__PUBLIC__/js/localtion/map.js"></script>
        <script>
 
var map=new Map();
            function xl(){
                var lyy=document.getElementById('lyyc');
                var xqy=document.getElementById('xqyc');
               var cq=document.getElementById("xq");
               var e=document.getElementById("ly");
               var dy=document.getElementById("dy");
                 xqy.value=cq.options[cq.selectedIndex].text;
               var obj = {};
                obj.id = cq.value;
                  e.length=0;
         $.post("{:U('Guanlixiaoqu/fwadd_change')}", obj,
         function(data,status) {
          if(data){
         var list = eval("("+data+")");   
          for(var i in list){   
             e[i]=new Option(list[i].lyname,list[i].id);
         map.put(list[i].id,list[i].dynumber);
 }    
       }else{
           
       }
     lyy.value=e.options[e.selectedIndex].text;
     dy.length=0;
      var dys=map.get(e.value);
      
      for(var i=1;i<=dys;i++){
          
          dy[i-1]=new Option(i+"单元",i);
          
      }

   
    
      });

            }
            
            function fw(){
                   var dy=document.getElementById("dy");
                var lyyc=document.getElementById('lyyc');
                var stt=document.getElementById('ly');
                lyyc.value=stt.options[stt.selectedIndex].text;
                dy.length=0;
                var dys=map.get(stt.value);
      
      for(var i=1;i<=dys;i++){
          
          dy[i-1]=new Option(i+"单元",i);
          
      }
                
            }

            
            
            </script>
</body>
</html>